Kludge up Mac usb/filesystem transparency on Garmin. Read or write "usb:" on
authorrobertl <robertl>
Mon, 8 Sep 2008 05:06:01 +0000 (05:06 +0000)
committerrobertl <robertl>
Mon, 8 Sep 2008 05:06:01 +0000 (05:06 +0000)
a Colorado or Zumo and the right thing will happen.

garmin_device_xml.c
jeeps/gpslibusb.c

index 0e7222b0a42d3e44f52a2969091f2a497a96836f..261422d19fdf5968690d0c2973c49d27b4f7dc7f 100644 (file)
@@ -71,8 +71,9 @@ void dir_s(const char *args, const char **unused) {
        mountpoint, GB_PATHSEP, path);
    my_gdx_info->from_device.basename = xstrdup(base);
    my_gdx_info->from_device.extension = xstrdup(ext);
-   xasprintf(&my_gdx_info->from_device.canon, "%s.%s",
+   xasprintf(&my_gdx_info->from_device.canon, "%s/%s.%s",
      my_gdx_info->from_device.path, 
+     my_gdx_info->from_device.basename, 
      my_gdx_info->from_device.extension);
   } else
   if (0 == strcmp(args, "InputToUnit")) {
@@ -125,7 +126,7 @@ gdx_find_file(char **dirlist) {
   const gdx_info *gdx;
   while (*dirlist) {
     char *tbuf;
-    xasprintf(&tbuf, "%s/%s", *dirlist, "GarminDevice.xml");
+    xasprintf(&tbuf, "%s/%s", *dirlist, "/Garmin/GarminDevice.xml");
     mountpoint = *dirlist;
     gdx = gdx_read(tbuf);
     xfree(tbuf);
index 3ddb08464b34838fd439c8c71ccffcdae204605b..a2c5be780ad4c482f5554b41ccd6446b1bbd7ae4 100644 (file)
@@ -61,6 +61,34 @@ static usb_dev_handle *udev;
 static int garmin_usb_scan(libusb_unit_data *, int);
 static const gdx_info *gdx;
 
+
+#if __linux__
+static
+char ** os_get_garmin_mountpoints() 
+{
+       // Hacked for testing.
+       return { ".", NULL };
+}
+#elif __APPLE__
+// In fantasy land, we'd query iokit for enumerated devices of the Garmin
+// vendor ID and match that against the mounted device table.  In practical
+// matters, that's crazy complex and this is where the devices seems to always
+// get mounted...
+char ** os_get_garmin_mountpoints() 
+{
+       char **dlist = xcalloc(2, sizeof *dlist);
+       dlist[0] = xstrdup("/Volumes/GARMIN");
+       dlist[1] = NULL;
+       return dlist;
+}
+#elif
+char ** os_get_garmin_mountpoints() 
+{
+       return {NULL};
+}
+#endif
+
+
 static int
 gusb_libusb_send(const garmin_usb_packet *opkt, size_t sz)
 {
@@ -291,11 +319,16 @@ int garmin_usb_scan(libusb_unit_data *lud, int req_unit_number)
                        /* Probably too promiscious of a match, but since
                         * Garmin doesn't document the _proper_ matching,
                         * we just take the easy way out for now.
+                        * Unfortunatey, blowing on DeviceClass == Mass storage
+                        * doesn't work on CO, at least.
                         */
                        if (dev->descriptor.idVendor == GARMIN_VID) {
-                               /* Nuvi */
-                               if (dev->descriptor.idProduct == 0x19) 
-                                       continue;
+                               switch (dev->descriptor.idProduct) {
+                                       case 0x19:  // Nuvi;
+                                       case 0x2244:  // Zumo;
+                                       case 0x2295:  // CO;
+                                               continue;
+                               }
                                if (req_unit_number < 0) {
                                        garmin_usb_start(dev);  
                                        /* 
@@ -325,7 +358,7 @@ int garmin_usb_scan(libusb_unit_data *lud, int req_unit_number)
                 * that is wants to read and write GPX files on a 
                 * mounted drive.  Try that now.
                 */
-char *dlist[] = { ".", NULL}; 
+               char **dlist = os_get_garmin_mountpoints();
                gdx = gdx_find_file(dlist);
                if (gdx) return 1;
                /* Plan C. */